<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>医生列表</title>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
    integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous" />
  <link rel="stylesheet" href="./Css/homePage.css">
  <link rel="stylesheet" href="./Css/doctorAdmin.css" />
  <script src="./units/jquery-3.6.0.js"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
    integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd"
    crossorigin="anonymous"></script>
</head>

<body>
  <div class="container-fluid">
    <div class="header">
      <div class="title">
        <p><span>互联网医疗服务后台管理</span>
        <div class="icon">
          <div class="glyphicon glyphicon-user"><a id="username" href="./doctorAdmin.html">admin</a></div>
          <div class="glyphicon glyphicon-home"><a href="./homePage.html">首页</a></div>
          <div class="glyphicon glyphicon-off"><a href="./login.html">退出</a></div>
        </div>
        </p>
      </div>
    </div>
    <div class="body">
      <div class="nav" id="nav">
        <li>
          <h4><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u21.svg" alt=""
              style="top:5px ;"><a href="./homePage.html">首页</a></h4>
        </li>
        <li>
          <div><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u19.svg"
              alt="" id="jiantou"></div>
          <h4><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u29.png"
              alt=""> 医生管理</h4>
          <ul class="nav nav-pills nav-stacked">
            <li role="presentation"><a href="./doctorAdmin.html">医生列表</a></li>
            <li role="presentation"><a href="./doctorReview.html">医生审核</a></li>
            <li role="presentation"><a href="./serviceAudit.html">服务审核</a></li>
          </ul>
        </li>
        <li>
          <h4><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u23.png"
              alt=""><a href="./userAdmin.html">用户管理</a></h4>
        </li>
        <li>
          <h4><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u34.svg"
              alt=""><a href="./prescriptionAdmin.html">处方管理</a></h4>
        </li>
        <li>
          <div><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u19.svg"
              alt="" id="jiantou"></div>
          <h4><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u41.svg"
              alt=""> 订单管理</h4>
          <ul class="nav nav-pills nav-stacked">
            <li role="presentation"><a href="./consultationListManagement.html">问诊单管理</a></li>
            <li role="presentation"><a href="./registrationOrderManagement.html">挂号单管理</a></li>
            <li role="presentation"><a href="./drugOrderManagement.html">药品订单管理</a></li>
          </ul>
        </li>
        <li>
          <div><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u19.svg"
              alt="" id="jiantou"></div>
          <h4><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u42.png"
              alt=""> 财务管理</h4>
          <ul class="nav nav-pills nav-stacked">
            <li role="presentation"><a href="./transactions.html">交易记录</a></li>
            <li role="presentation"><a href="./settlementAdmin.html">结算管理</a></li>
            <li role="presentation"><a href="./transferAdmin.html">转账管理</a></li>
          </ul>
        </li>
        <li>
          <div><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u19.svg"
              alt="" id="jiantou"></div>
          <h4><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u44.png"
              alt=""> 商品管理</h4>
          <ul class="nav nav-pills nav-stacked">
            <li role="presentation"><a href="./commodityManagement.html">药品列表</a></li>
            <li role="presentation"><a href="#">药品分类</a></li>
            <li role="presentation"><a href="#">药品审核</a></li>
          </ul>
        </li>
        <li>
          <div><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u19.svg"
              alt="" id="jiantou"></div>
          <h4><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u48.svg"
              alt=""> 运营管理</h4>
          <ul class="nav nav-pills nav-stacked">
            <li role="presentation"><a href="./runningManage.html">优惠券管理</a></li>
            <li role="presentation"><a href="./runningManageSystem.html">系统消息</a></li>
            <li role="presentation"><a href="#">APP推送消息</a></li>
            <li role="presentation"><a href="#">短信消息</a></li>
            <li role="presentation"><a href="#">广告管理</a></li>
            <li role="presentation"><a href="#">活动管理</a></li>
          </ul>
        </li>
        <li>
          <div><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u19.svg"
              alt="" id="jiantou"></div>
          <h4><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u51.png"
              alt=""> 内容管理</h4>
          <ul class="nav nav-pills nav-stacked">
            <li role="presentation"><a href="./carouselPage.html">轮播图管理</a></li>
            <li role="presentation"><a href="./diseasePage.html">疾病科普</a></li>
            <li role="presentation"><a href="#">医院管理</a></li>
            <li role="presentation"><a href="#">医院科室管理</a></li>
            <li role="presentation"><a href="#">药店管理</a></li>
            <li role="presentation"><a href="#">平台科室管理</a></li>
            <li role="presentation"><a href="./questionPage.html">常见问题</a></li>
          </ul>
        </li>
        <li>
          <div><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u19.svg"
              alt="" id="jiantou"></div>
          <h4><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u54.png"
              alt=""> 统计</h4>
          <ul class="nav nav-pills nav-stacked">
            <li role="presentation"><a href="./tradeStatic.html">交易统计</a></li>
            <li role="presentation"><a href="./userStatic.html">用户统计</a></li>
            <li role="presentation"><a href="./docotorStatic.html">医生统计</a></li>
          </ul>
        </li>
        <li>
          <div><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u19.svg"
              alt="" id="jiantou"></div>
          <h4><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u57.svg"
              alt=""> 设置</h4>
          <ul class="nav nav-pills nav-stacked">
            <li role="presentation"><a href="./messageReminder.html">消息提醒</a></li>
            <li role="presentation"><a href="./basicSettings.html">基本设置</a></li>
          </ul>
        </li>
        <li>
          <div><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u19.svg"
              alt="" id="jiantou"></div>
          <h4><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u62.png"
              alt=""> 权限</h4>
          <ul class="nav nav-pills nav-stacked">
            <li role="presentation"><a href="#">成员管理</a></li>
            <li role="presentation"><a href="#">角色管理</a></li>
            <li role="presentation"><a href="#">操作日志</a></li>
            <li role="presentation"><a href="#">数据库管理</a></li>
          </ul>
        </li>
        <li>
          <h4><img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/系统架构/u61.png"
              alt=""><a href="./userAdmin.html">意见管理</a></h4>
        </li>
      </div>
      <div class="doctorAdminShow">
        <h3 style="font-weight: bold;">医生管理</h3>
        <div class="doctorScreening">
          <div class="shortcuts">
            <img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/服务审核/u212.png" alt="">
            <p>筛选</p>
          </div>
          <div class="doctorScreeningBox">
            <div class="form-group" style="margin-bottom: 0px;">
              <input placeholder="输入医生姓名" type="text" class="form-control searchInp">
            </div>

            <div class="dropDownChoice1">
              <ul class="nav nav-tabs">
                <li role="presentation" class="dropdown">
                  <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true"
                    aria-expanded="false">
                    <span id="choiceText1">请选择科室</span><span class="caret"></span>
                  </a>
                  <ul id="choiceTextLi1" class="dropdown-menu">
                    <li>内分泌科</li>
                    <li>内科</li>
                    <li>消化科</li>
                    <li>儿科</li>
                    <li>中医科</li>
                  </ul>
                </li>
              </ul>
            </div>
            <div class="dropDownChoice2">
              <ul class="nav nav-tabs">
                <li role="presentation" class="dropdown">
                  <a class="dropdown-toggle" data-toggle="dropdown" href="" role="button" aria-haspopup="true"
                    aria-expanded="false">
                    <span id="choiceText2">请选择职称</span><span class="caret"></span>
                  </a>
                  <ul id="choiceTextLi2" class="dropdown-menu">
                    <li>主任医师</li>
                    <li>副主任医师</li>
                    <li>主治医师</li>
                    <li>住院医师</li>
                    <li>药剂师</li>
                    <li>护师</li>
                  </ul>
                </li>
              </ul>
            </div>
            <div class="choiceBtn">
              <span>筛选</span>
            </div>
            <div class="choiceBtn" id="add">
              <span>添加</span>
            </div>
          </div>
        </div>
        <div class="doctorList">
          <div class="shortcuts">
            <img src="https://cimg.axureshop.com/90/7b/9a/907b9a01ce1f49f0a29a8c9909478853/images/服务审核/u214.svg" alt="">
            <p>医生列表</p>
          </div>
          <p></p>
          <div class="doctorListBox">
            <table class="table table-striped table-bordered table-hover">
              <thead>
                <tr>
                  <th>选择</th>
                  <th>编号</th>
                  <th>姓名</th>
                  <th>电话</th>
                  <th>医院</th>
                  <th>科室</th>
                  <th>职称</th>
                  <th>加入时间</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
                <!-- <tr>
                          <td>
                            <input type="checkbox" name="" id="" />
                          </td>
                          <td>id</td>
                          <td>医生</td>
                          <td>18811112345</td>
                          <td>北大医院</td>
                          <td>内科</td>
                          <td>主任医师</td>
                          <td>2020-02-07 21：00：00</td>
                          <td>                            
                              <button class="btn btn-primary">编辑</button>
                              <button class="btn btn-danger">删除</button>
                          </td>
                      </tr> -->
              </tbody>
            </table>
            <div class="tableNavBox">
              <div class="choiceAll">
                <input type="checkbox" name="1" id="" />
                <span>全选</span>
              </div>
              <div class="batchDelete" style="margin-top: 2px;"><span>批量删除</span></div>
              <div class="batchChoice" style="margin-top: 2px;"><span></span></div>
              <div class="tableNav">
                <nav aria-label="Page navigation">
                  <ul class="pagination">
                    <li>
                      <a href="#" class="prev">
                        <span>&laquo;</span>
                      </a>
                    </li>
                    <!-- <li class="active"><a href="#">1</a></li>
                            <li><a href="#">2</a></li>
                            <li><a href="#">3</a></li>
                            <li><a href="#">4</a></li>
                            <li><a href="#">5</a></li> -->
                    <li>
                      <a href="#" class="next">
                        <span>&raquo;</span>
                      </a>
                    </li>
                  </ul>
                </nav>
              </div>
            </div>

          </div>
        </div>
      </div>
    </div>
  </div>

  <!-- 添加 -->
  <!-- id: 10,
    name: "医生10",
    tel: "18811112345",
    hospital: "华西医院",
    department: "中科医",
    title: "中医科",
    joinTime: "2020-02-07 21：00：00", -->
  <div class="modal fade" id="addModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"><span>&times;</span></button>
          <h4 class="modal-title" id="myModalLabel">医生添加</h4>
        </div>
        <div class="modal-body">
          <form>
            <div class="form-group">
              <label for="exampleInputName2">编号</label>
              <input type="text" class="form-control addId">
            </div>
            <div class="form-group">
              <label for="exampleInputName2">姓名</label>
              <input type="text" class="form-control addName">
            </div>
            <div class="form-group">
              <label for="exampleInputName2">电话</label>
              <input type="text" class="form-control addTel">
            </div>
            <div class="form-group">
              <label for="exampleInputName2">医院</label>
              <input type="text" class="form-control addHospital">
            </div>
            <div class="form-group">
              <label for="exampleInputName2">科室</label>
              <input type="text" class="form-control addDepartment">
            </div>
            <div class="form-group">
              <label for="exampleInputName2">职称</label>
              <input type="text" class="form-control addTitle">
            </div>
            <div class="form-group">
              <label for="exampleInputName2">加入时间</label>
              <input type="text" class="form-control addJoinTime">
            </div>
          </form>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
          <button type="button" class="btn btn-primary addSaveBtn">保存</button>
        </div>
      </div>
    </div>
  </div>

  <!-- 管理员信息编辑 -->
  <div class="modal fade" id="editModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"><span>&times;</span></button>
          <h4 class="modal-title" id="myModalLabel">管理员修改</h4>
        </div>
        <div class="modal-body">
          <form>
            <div class="form-group">
              <label for="exampleInputEmail1">编号</label>
              <input disabled type="text" class="form-control editId">
            </div>
            <div class="form-group">
              <label for="exampleInputPassword1">姓名</label>
              <input type="text" class="form-control editName">
            </div>
            <div class="form-group">
              <label for="exampleInputPassword1">电话</label>
              <input type="text" class="form-control editTel">
            </div>
            <div class="form-group">
              <label for="exampleInputPassword1">医院</label>
              <input disabled type="text" class="form-control editHospital">
            </div>
            <div class="form-group">
              <label for="exampleInputPassword1">科室</label>
              <input type="text" class="form-control editDepartment">
            </div>
            <div class="form-group">
              <label for="exampleInputPassword1">职称</label>
              <input type="text" class="form-control editTitle">
            </div>
            <div class="form-group">
              <label for="exampleInputPassword1">加入时间</label>
              <input disabled type="text" class="form-control editJoinTime">
            </div>
          </form>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
          <button type="button" class="btn btn-primary editSaveBtn">保存</button>
        </div>
      </div>
    </div>
  </div>

  <!-- 提醒模块 -->
  <div class="modal fade" id="delModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
      <div class="modal-content">

        <div class="modal-body">
          您确定要删除？
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
          <button type="button" class="btn btn-primary delBtn">确定</button>
        </div>
      </div>
    </div>
  </div>
  <script src="./js/homePage.js"></script>
<!--   <script>
    // 获取下拉信息
    let oChoiceText1 = document.querySelector("#choiceText1");
    let aLi1 = document.querySelectorAll("#choiceTextLi1 li");
    let oChoiceText2 = document.querySelector("#choiceText2");
    let aLi2 = document.querySelectorAll("#choiceTextLi2 li");
    for (let i = 0; i < aLi1.length; i++) {
      aLi1[i].onclick = function () {
        oChoiceText1.innerHTML = this.innerHTML;
      };
    }
    for (let i = 0; i < aLi2.length; i++) {
      aLi2[i].onclick = function () {
        oChoiceText2.innerHTML = this.innerHTML;
      };
    }

    //当前的页码
    let page = 1;
    //每页的条数
    let count = 6;
    //获取tbody
    let oTBody = document.querySelector("tbody");
    //获取分页容器
    let oPagination = document.querySelector(".pagination");
    //获取上一页的按钮
    let oPrevBtn = document.querySelector(".prev");
    //获取下一页的按钮
    let oNextBtn = document.querySelector(".next");
    //获取搜索的输入框 #choiceText1 #choiceText2
    let oSearchInp = document.querySelector(".searchInp");
    let oSearchInp1 = document.querySelector("#choiceText1");
    let oSearchInp2 = document.querySelector("#choiceText2");
    //获取搜索按钮.choiceBtn
    let oSearchBtn = document.querySelector(".choiceBtn");
    //获取修改的保存
    let oEditSaveBtn = document.querySelector(".editSaveBtn");
    // 分页数据
    let dataPage = document.querySelector(".batchChoice span");

    //初始化
    function render() {
      //查看搜索框的内容
      let str1 = oSearchInp.value;
      let str2 = oSearchInp1.innerHTML; //搜索的内容2
      let str3 = oSearchInp2.innerHTML; //搜索的内容3
      let searchData = []; //最终用来渲染的;
      let data1 = [];
      let data2 = [];
      //一上来获取数据
      $.ajax({
        url: '/getShops',
        method: 'get',
        success: ({ data }) => {
          data.forEach((v) => {
            let data = v;
            if (str1.trim() == "") {

              data1 = data;
            } else {
              data1 = data.filter(function (v) {
                // if(v.name.includes(str1)){
                //     return v
                // }
                return v.name.includes(str1);
              });
            }

            if (str2 == "请选择科室") {
              data2 = data1;
            } else {
              data2 = data1.filter(function (v) {
                /*  if(v.user.includes(str2)){
                        return v
                    } */
                return v.department.includes(str2);
              });
            }

            if (str3 == "请选择职称") {
              searchData = data2;
            } else {
              searchData = data2.filter(function (v) {
                return v.title.includes(str3);
              });
            }
          })
        }
      })


      //让table为空
      oTBody.innerHTML = "";
      //根据count和page准备要渲染的数据
      let renderArr = searchData.slice((page - 1) * count, page * count);
      //循环要渲染的数据

      //一上来获取数据
      $.ajax({
        url: '/getDoctors',
        method: 'get',
        success: ({ data }) => {
          data.forEach((v, i) => {
            //创建tr
            let oTr = document.createElement("tr");
            //给tr创建内容
            /* 
            id: 10,
            name: "医生10",
            tel: "18811112345",
            hospital: "华西医院",
            department: "中科医",
            title: "中医科",
            joinTime: "2020-02-07 21：00：00",
             */
            oTr.innerHTML = `
            <td><input type="checkbox" name="" id="" /></td>
            <td>${v.id}</td>
            <td>${v.name}</td>
            <td>${v.tel}</td>
            <td>${v.hospital}</td>
            <td>${v.department}</td>
            <td>${v.title}</td>
            <td>${v.joinTime}</td>
            <td>
                <button class="btn btn-primary edit">编辑</button>
                <button class="btn btn-danger del">删除</button>
            </td>
        `;
            //把tr创建到tbody里面
            oTBody.appendChild(oTr);

          })
        }
      })
      for (let i = 0; i < renderArr.length; i++) {
        //创建tr
        let oTr = document.createElement("tr");

        //给tr创建内容
        /* 
        id: 10,
        name: "医生10",
        tel: "18811112345",
        hospital: "华西医院",
        department: "中科医",
        title: "中医科",
        joinTime: "2020-02-07 21：00：00",
         */
        oTr.innerHTML = `
    <td><input type="checkbox" name="" id="" /></td>
    <td>${renderArr[i].id}</td>
    <td>${renderArr[i].name}</td>
    <td>${renderArr[i].tel}</td>
    <td>${renderArr[i].hospital}</td>
    <td>${renderArr[i].department}</td>
    <td>${renderArr[i].title}</td>
    <td>${renderArr[i].joinTime}</td>
    <td>
        <button class="btn btn-primary edit">编辑</button>
        <button class="btn btn-danger del">删除</button>
    </td>
`;
        //把tr创建到tbody里面
        oTBody.appendChild(oTr);
      }
      //渲染页码
      //找到所有的1，2，3，4的页码
      let aPageBtn = document.querySelectorAll(".pageBtn");
      //删除所有的页码
      for (let i = 0; i < aPageBtn.length; i++) {
        oPagination.removeChild(aPageBtn[i].parentNode);
      }
      //根据数据的长度重新创建页码
      let L = Math.ceil(searchData.length / count);
      for (let i = 1; i <= L; i++) {
        //创建li
        let oLi = document.createElement("li");
        //给li创建内容
        oLi.innerHTML = `<a class="pageBtn" href="#">${i}</a>`;
        //如果li和当前的页码一致，给他加一个选中的class
        if (i == page) {
          oLi.classList.add("active");
        }
        //在下一页的前面插入页码
        oPagination.insertBefore(oLi, oPagination.lastElementChild);

        // 显示数据条数
        dataPage.innerHTML = "共" + L + "页/" + (searchData.length + 1) + "条数据";
      }

      //联动全选
      let oChoiceAllInp = document.querySelector(".choiceAll input");
      let aChoiceAllInp = oTBody.querySelectorAll("input");
      let n = 0; //计数
      oChoiceAllInp.checked = false;

      oChoiceAllInp.addEventListener("click", choiceAllFn);

      function choiceAllFn() {
        if (oChoiceAllInp.checked == true) {
          for (let i = 0; i < aChoiceAllInp.length; i++) {
            aChoiceAllInp[i].checked = true;
          }
        } else {
          for (let i = 0; i < aChoiceAllInp.length; i++) {
            aChoiceAllInp[i].checked = false;
          }
          n = 0;
        }
      }

      for (let i = 0; i < aChoiceAllInp.length; i++) {
        aChoiceAllInp[i].onclick = function () {
          //判断当前选没选中
          if (this.checked == true) {
            n++;
          } else {
            n--;
          }

          if (n == aChoiceAllInp.length) {
            //全部都被选中
            oChoiceAllInp.checked = true;
          } else {
            oChoiceAllInp.checked = false;
          }
        };
      }
    }
    // 初始化渲染
    render();

    //给分页加事件
    /* 
            每页是5条  count
            data  
        1   0-5
        2   5-10
        3   10-15
        n   (n-1)*count   n*count
    -----------------------------
            data  每页是5条  count 
        
        1    1
        5    1
        6    2
        10   2
        11   3
        n    Math.ceil(n/count)
     */
    oPagination.addEventListener("click", changePage);
    function changePage() {
      //如果当前点击的按钮有pageBtn这个class名字
      if (event.target.className == "pageBtn") {
        //修改全局的page
        page = event.target.innerText;
        //渲染table，渲染分页
        render();
      }
    }
    //给上一页和下一页加事件
    oPrevBtn.addEventListener("click", prev);
    oNextBtn.addEventListener("click", next);
    function prev() {
      if (page > 1) {
        page--;
        render();
      }
    }
    function next() {
      if (page < Math.ceil(data.length / count)) {
        page++;
        render();
      }
    }
    //搜索
    oSearchBtn.addEventListener("click", searchFn);
    function searchFn() {
      page = 1;
      render();
    }
    //删除功能
    let delId; //重置的id
    oTBody.addEventListener("click", openDel);
    function openDel() {
      if (event.target.className.includes("del")) {
        $("#delModal").modal("show");
        delId = event.target.parentNode.parentNode.children[1].innerText;
      }
    }
    let delBtn = document.querySelector(".delBtn");
    delBtn.addEventListener("click", delIt);
    function delIt() {
      for (let i = 0; i < data.length; i++) {
        if (data[i].id == delId) {
          data.splice(i, 1);
        }
      }
      $("#delModal").modal("hide");
      //重新渲染
      render();
    }

    //给所有的编辑按钮加事件
    oTBody.addEventListener("click", openEdit);
    function openEdit() {
      //判断事件源
      if (event.target.className.includes("edit")) {
        //让编辑框显示
        $("#editModal").modal("show");
        //确认是那个id的数据
        let id = event.target.parentNode.parentNode.children[1].innerText;
        //循环数据，找到对应id的，给编辑框赋值
        for (let i = 0; i < data.length; i++) {
          if (data[i].id == id) {
            document.querySelector(".editId").value = data[i].id;

            document.querySelector(".editName").value = data[i].name;

            document.querySelector(".editTel").value = data[i].tel;

            document.querySelector(".editHospital").value = data[i].hospital;

            document.querySelector(".editDepartment").value = data[i].department;

            document.querySelector(".editTitle").value = data[i].title;

            document.querySelector(".editJoinTime").value = data[i].joinTime;
          }
        }
      }
    }
    //点击修改保存
    oEditSaveBtn.addEventListener("click", editSave);
    function editSave() {
      //看替换的是哪一条；
      let id = document.querySelector(".editId").value;
      //循环数据，找到对应的，更改
      for (let i = 0; i < data.length; i++) {
        if (data[i].id == id) {
          data[i].name = document.querySelector(".editName").value;
          data[i].tel = document.querySelector(".editTel").value;
          data[i].hospital = document.querySelector(".editHospital").value;
          data[i].department = document.querySelector(".editDepartment").value;
          data[i].title = document.querySelector(".editTitle").value;
          data[i].joinTime = document.querySelector(".editJoinTime").value;
        }
      }
      //关闭弹框
      $("#editModal").modal("hide");
      //重新渲染
      render();
    }
    // 批量删除功能
    /*
        当点击了批量删除    
        将勾选了的 tr全部删除  遍历  将勾选了的input的tr另存在一个数组里
        并删除数据
     */
    // 获取批量删除
    let oBatchChoice = document.querySelector(".batchDelete");
    let deleteArr = []; //存删除的tr
    let checkId = []; //存被删除的 tr 的id
    oBatchChoice.addEventListener("click", deleteAllFn);
    function deleteAllFn() {
      aInp = document.querySelectorAll("tbody>tr>td>input");
      for (let i = 0; i < aInp.length; i++) {
        if (aInp[i].checked == true) {
          deleteArr.push(aInp[i]);
        }
      }
      console.log(deleteArr);
      for (let j = 0; j < deleteArr.length; j++) {
        // 找到每一项的id  存在数组里
        checkId.push(deleteArr[j].parentNode.parentNode.children[1].innerText);
      }
      console.log(checkId);
      // 根据id删除对应的数据 然后进行数据渲染
      for (let i = 0; i < checkId.length; i++) {
        for (let j = 0; j < data.length; j++) {
          if (checkId[i] == data[j].id) {
            //删除id所对应的数据
            data.splice(j, 1);
          }
        }
      }
      //重新渲染
      render();
      deleteArr = [];
      checkId = [];
    }
  </script> -->
  <script src="./JS/doctorAdmin.js"></script>
</body>

</html>